<template>
     <div class="login">
        <div class="login1"></div>
        <div class="login2">
            <div class="login2_div1">
                <div class="login2_div1_title1">
                    <p class="login2_div1_title1_content1" @click="cgeTab(1)">账号密码登陆</p>
                </div>

            <el-input placeholder="请输入账号" v-model="param.username" />
            <p style="height: 30px;"></p>


            <el-input auto-complete v-model="param.password" placeholder="请输入密码" show-password />
            <p style="height: 40px;"></p>

                    <p style="height: 40px;"></p>
                    <el-button :loading="loading" type="primary" @click="tologin" class="ww100">登 录</el-button>
                </div>
            </div>
        </div>


</template>
<script>
    
    export default {
    data() {
        return {
            param:{},
        }
    },

    created() {
    },

    mounted() {
    },

    components: {
    },

    methods: {
        tologin(){
            var that = this;
            that.loading = true;
            let result;
            // localStorage.clear();
            // this.$store.commit('setToken', '');
            that.$api.login(that.param).then(result => {
            console.log(result, 'result===========');
            if (result) {
                that.$store.commit('setToken',result.token);
                that.$store.commit('setInfo',result);
                // that.$router.push('/settled');
                setTimeout(() => {
                    that.loading = false;
                    // that.$router.push('/');

                    // that.$api.getAdminWithTheMenuTree().then(res=>{
                    //     console.log(res,'权限管理-------');
                    //     if(res){ 
                            that.$store.commit('setMenuList','');
                            let arr = result.adminMenus

                            arr.forEach(val => {
                                console.log(val.children.length,'val.children.length');
                                if (val.children.length <= 0) { 
                                    delete val.children
                                }
                            });
                            console.log(arr,'权限管理1111111111-------');
                            that.$store.commit('setMenuList',arr);
                            setTimeout(() => {
                                that.loading = false;
                                that.$router.push('/yonghuliebiao');
                            }, 300);
                        // }else{
                        //     that.loading = false;
                        // }
                    // })
                }, 150);
            } else {
                that.loading = false;
            }
            })
        },



    }

}

</script>
<style lang="scss" scoped>
.twolinks {
    display: flex;
    justify-content: space-evenly;
    width: 100%;
    font-weight: 400;
    font-size: 14px;
    padding: 30px 40px 14px;
    box-sizing: border-box;
    // border-bottom: 1px dashed #CCCCCC;
}

.login {
    min-height: 100vh;
    display: flex;
    background: #fff;

    :deep .el-input__inner,
    .el-button {
        height: 48px;
        line-height: 48px;
        font-size: 16px;
    }

    :deep .el-input__inner {
        padding: 0 20px;
    }
}

.login1 {
    flex: 1;
    background: url(../../assets/imgs/li.png) no-repeat center center;
    background-size: cover;
}

.login2 {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;

    .login2_div1 {
        display: block;
        width: 370px;
        .login2_div1_title1{
            text-align: center;
            font-size: 26px;
            margin-bottom: 30px;
            .login2_div1_title1_content1{
                font-weight: 600;
                color: #242424;
            }
        }
    }
}


</style>